#include "easy.h"
#include"mainwidget.h"
#include"gamewidge.h"
#include<QWidget>
#include<QVBoxLayout>
#include<QIcon>
#include<QBrush>
#include<QLabel>
#include<QPushButton>
#include<QGraphicsView>
#include<QResizeEvent>
#include<QTimer>
#include<QPoint>
#include<QLineF>
#include<QMouseEvent>

Easy::Easy()
{
    this->resize(1500,799);
    this->setWindowTitle("STAR WARS");
    this->setWindowIcon(QIcon("img/DS.png"));

    this->setBackgroundBrush(QBrush(QPixmap("img/BG1.png")));

    this->setMouseTracking(true);

    scence=new QGraphicsScene;
    scence->setSceneRect(0,0,this->width()-2,this->height()-2);
    this->setScene(scence);

    gun=new Qgun("img/pao",scence);
    gun->setPos(this->width()/2,this->height());
    scence->addItem(gun);

    fish1=new QFish("img/fish1.png",scence);
    fish1->setPos(100,500);
    scence->addItem(fish1);



    timer =new QTimer;
    connect(timer,SIGNAL(timeout()),scence,SLOT(advance()));
    timer->start(100);

}

void Easy::resizeEvent(QResizeEvent *event)
{
    this->setBackgroundBrush(QBrush(QPixmap("img/BG1.png").scaled(event->size())));
}

void Easy::mouseMoveEvent(QMouseEvent *event)
{


}

void Easy::mousePressEvent(QMouseEvent *event)
{
    QPoint p=event->pos();
    QLineF linef(this->width()/2,this->height(),p.x(),p.y());
    QBullet *bullet=new QBullet("img/B.png",scence,linef.angle());

}
